/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-07-27
 * Time: 16:27
 */
public class demo1 {
    public static void main(String[] args) throws InterruptedException {
        Object o = new Object();
        Thread t1 = new Thread("a") {
            @Override
            public void run() {
                synchronized (o) {
                    System.out.println(this.getName());
                }
            }
        };
        Thread t2 = new Thread("b") {
            @Override
            public void run() {
                synchronized (o) {
                    System.out.println(this.getName());
                }
            }
        };
        Thread t3 = new Thread("c") {
            @Override
            public void run() {
                synchronized (o) {
                    System.out.println(this.getName());
                }
            }
        };
        t3.start();
        t3.join();
        t2.start();
        t2.join();
        t1.start();
        t1.join();
    }
}
